package com.wsoft.oss.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import org.springframework.lang.Nullable;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;

/**
 * @author z001
 * @Date 2024/9/26 18:39
 */
@Getter
public enum FileSizeEnum {
    /**
     * 最小图片
     */
    MIN("MIN", 1,365,200),
    /**
     * 中间图片
     */
    MID("MID", 2,1024,768),
    /**
     * 最大图片
     */
    MAX("MAX", 3,1024,768);

    private final String type;

    private final Integer value;

    private final Integer width;

    private final Integer height;

    private static final Map<String, FileSizeEnum> TYPE_MAPPING = new HashMap(16);
    private static final Map<Integer, FileSizeEnum> VALUE_MAPPING = new HashMap(16);


    FileSizeEnum(String type, Integer value,Integer width,Integer height) {
        this.type = type;
        this.width = width;
        this.height = height;
        this.value = value;
    }

    static {
        FileSizeEnum[] var0 = values();
        for (FileSizeEnum fileSizeEnum : var0) {
            TYPE_MAPPING.put(fileSizeEnum.getType(), fileSizeEnum);
            VALUE_MAPPING.put(fileSizeEnum.getValue(), fileSizeEnum);
        }
    }


    @NotNull
    public static FileSizeEnum resolve(@Nullable String type) {
        if (StrUtil.isNotBlank(type)) {
            return TYPE_MAPPING.get(type);
        }
        return null;
    }
    @NotNull
    public static FileSizeEnum resolve(@Nullable Integer value) {
        if (null != value) {
            return VALUE_MAPPING.get(value);
        }
        return null;
    }

}
